/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pt.utl.ist.isr.livetrack.ui;

import java.awt.Image;
import java.awt.event.ActionEvent;
import javax.swing.Action;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.util.HelpCtx;
import org.openide.util.ImageUtilities;
import org.openide.util.NbBundle;
import org.openide.util.Utilities;
import org.openide.util.actions.SystemAction;
import pt.utl.ist.isr.livetrack.server.LTServer;

/**
 *
 * @author David Miguel Antunes <davidmiguel [ at ] antunes.net>
 */
public class ZonesNode extends AbstractNode {

    private Action[] actions = new Action[]{
        new SystemAction() {

            @Override
            public String getName() {
                return NbBundle.getMessage(this.getClass(), "NewZone");
            }

            @Override
            public HelpCtx getHelpCtx() {
                return null;
            }

            @Override
            public void actionPerformed(ActionEvent ev) {
                ZonesNode n = Utilities.actionsGlobalContext().lookup(ZonesNode.class);
                new NewZoneWizardAction(n.server.getPerimeter()).actionPerformed(null);
                ZonesNodeChildFactory.getFactory(n.server).refresh();
            }
        }};
    private LTServer server;

    public ZonesNode(LTServer server) {
        super(Children.create(ZonesNodeChildFactory.getFactory(server), false));
        this.server = server;
        setDisplayName(NbBundle.getMessage(this.getClass(), "ZonesNode_title"));
    }

    @Override
    public Action[] getActions(boolean context) {
        return actions;
    }

    @Override
    public Image getIcon(int type) {
        return ImageUtilities.loadImage("pt/utl/ist/isr/livetrack/ui/icons/zones.gif", true);
    }

    @Override
    public Image getOpenedIcon(int type) {
        return ImageUtilities.loadImage("pt/utl/ist/isr/livetrack/ui/icons/zones.gif", true);
    }
}
